<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>北京石鸣科技有限责任公司用户注册</title>
<link rel="stylesheet" href="static/css/style.css">
<body>

<div class="register-container">
	<h1>北京石鸣科技有限责任公司用户注册</h1>
	
	<div class="connect">
		<p>以下信息我们绝对不会外泄</p>
	</div>
	
	<div class="login_form">
					<form action="" id="regist_form" method="post">
						<div class="form-group">
							<label for="j_username" class="t" style="position: absolute;left: -73px;top: 35px;">邮 箱：</label> <input id="username" value="" name="username" type="text" onblur="checkUsername();" class="password form-control x319 in"><span id="usernamemsg" class="err" style="position: absolute;width: 200px;top: 36px;"></span>
						</div>
						<div class="form-group">
							<label for="j_password" class="t" style="position: absolute;left: -73px;top: 105px;">密 码：</label> <input id="password" value="" name="password" type="password" onblur="checkPassword();" class="password form-control x319 in"><span id="passwordmsg" class="err" style="position: absolute;width: 200px;top: 105px;"></span>

						</div>
						<div class="form-group">
							<label for="j_password" class="t" style="position: absolute;left: -73px;top: 175px;">确认密码：</label> <input id="repassword" value="" name="repassword" type="password" onblur="checkRepassword();" class="password form-control x319 in"> <span id="repasswordmsg" class="err" style="position: absolute;width: 200px;top: 177px;"></span>

						</div>
						<div class="form-group">
							<label for="j_password" class="t" style="position: absolute;left: -73px;top: 245px;">姓 名：</label> <input id="nick" value="" name="nick" type="text" onblur="checkName();" class="password form-control x319 in"> <span id="nameerrormsg" class="err" style="position: absolute;width: 200px;top: 243px;"></span>

						</div>
						<div class="form-group">
							<label for="j_password" class="t" style="position: absolute;left: -73px;top: 315px;">身份证：</label> <input id="idcard" value="" name="idcard" type="text" onblur="checkIdcard();" class="form-control x319 in" maxlength="18"> <span id="idcardmsg" class="err" style="position: absolute;width: 200px;top: 314px;"></span>

						</div>

						<div class="form-group">
							<label for="j_password" class="t" style="position: absolute;left: -73px;top: 385px;">手机号：</label> <input id="mobile" value="" name="mobile" type="text" onblur="checkMobile();" class="form-control x319 in"> <span id="mobilemsg" class="err" style="position: absolute;width: 200px;top: 382px;"></span>

						</div>
						
						
						
						<div class="form-group space">
							<label class="t"></label><!--disabled="disabled" -->
							<button type="button" id="submit_btn" name="submit" value="submit" onclick="dosubmit();" class="btn btn-primary btn-lg">&nbsp;注&nbsp;册&nbsp;</button>
							<input type="reset" value="&nbsp;重&nbsp;置&nbsp;" class="btn btn-default btn-lg">
						</div>
					</form>
				</div>
	<a href="index.html">
		<button type="button" class="register-tis">回到首页</button>
	</a>

</div>


<script src="static/js/jquery.min.js"></script>
<script>

$('#usernamemsg').html('');
	$('#passwordmsg').html('');
	$('#repasswordmsg').html('');
	$('#nameerrormsg').html('');
	$('#mobilemsg').html('');
	var errormsg="";
	function checkUsername(){
		var vusername = $('#username').val();
		var reg =  /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if(!reg.test(vusername)){
			errormsg="请输入正确的邮箱";
			$('#usernamemsg').html(errormsg);
		}else{
			$('#usernamemsg').html('');
		}	
	}

	function checkPassword(){
		var value = $('#password').val();
		var reg = /^[a-zA-Z0-9]{1,12}$/;
		if(!reg.test(value)){
			errormsg="请输入正确的密码";
			$('#passwordmsg').html(errormsg);	
		}else{
			$('#passwordmsg').html('');	
		}	
	}
	
	function checkRepassword(){
		var value = $('#password').val();
		var value2 = $('#repassword').val();
		
		if(value==value2){
			$('#repasswordmsg').html('');
		}else{
			errormsg="两次密码不一致";
			$('#repasswordmsg').html(errormsg);	
		}	
	}
	
	function checkName(){
		var value = $('#nick').val();
		var reg =   /^[\u4e00-\u9fa5]{2,5}$/;
		if(!reg.test(value)){
			errormsg="请输入正确的姓名";
			$('#nameerrormsg').html(errormsg);
		}else{
			$('#nameerrormsg').html('');
		}	
	}

	function checkIdcard(){
		var value = $('#idcard').val();
		var reg =/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
		if(!reg.test(value)){
			errormsg="请输入正确的身份证";
			$('#idcardmsg').html(errormsg);	
		}else{
			$('#idcardmsg').html('');
				var vnick = $('#nick').val();
				$.ajax({
				cache: false,
				type: "POST",
				url:'http://27.50.136.66:9010/tyxbweb/CheckIdcard',
				data:{
					idcard:value,
					nick:vnick
				},// 你的formid
				async: true,
				dataType :"json",
				success: function(data) {
					console.info(data);
					if(data.success){
						alert("身份证匹配");
						errormsg="";
						$('#idcardmsg').html(errormsg);	
						//window.location.href="http://localhost/index.html";
					}else{
						alert("身份证不匹配");
						errormsg="身份证信息不匹配";
						$('#idcardmsg').html(errormsg);	
					}
				}
			});
			
		}	
	}
	
	function checkMobile(){
		var value = $('#mobile').val();
		var reg =/^1[34578]\d{9}$/;
		if(!reg.test(value)){
			errormsg="请输入正确的手机号";
			$('#mobilemsg').html(errormsg);	
		}else{
			$('#mobilemsg').html('');
		}	
	}

	function dosubmit(){
		 checkUsername();checkPassword();checkRepassword();
	 checkName();checkMobile();
		if(errormsg!=''){
			alert("校验未通过"+errormsg);
			return false;
		}else{
			$.ajax({
				cache: true,
				type: "POST",
				url:'http://27.50.136.66:9010/tyxbweb/UserServlet?command=regist',
				data:$('#regist_form').serialize(),// 你的formid
				async: false,
				dataType :"json",
				success: function(data) {
					console.info(data);
					//var obj = jQuery.parseJSON(data);
					//console.info(obj);
					if(data.success){
						alert("注册成功,即将跳转到登陆界面");
						//window.location.href="http://localhost/index.html";
						window.location.href="http://www.5iqmx.com.cn/login.html";//注册成功后跳转的页面
					}else{
						alert("注册失败请刷新后再试");
					}
				}
			});
		}
	}
</script>
<script src="static/js/common.js" tppabs="http://www.5iqmx.com.cn/static/js/common.js"></script>
<!--背景图片自动更换-->
<script src="static/js/supersized.3.2.7.min.js" tppabs="http://www.5iqmx.com.cn/static/js/supersized.3.2.7.min.js"></script>
<script src="static/js/supersized-init.js" tppabs="http://www.5iqmx.com.cn/static/js/supersized-init.js"></script>
<!--表单验证-->
<script src="static/js/jquery.validate.min.js" tppabs="http://www.5iqmx.com.cn/static/js/jquery.validate.min.js"></script>

</body>
</head></html>
